<%@ page import="jakarta.servlet.http.Cookie" %><%--
  Created by IntelliJ IDEA.
  User: wenze-zero
  Date: 2021-06-03-003
  Time: 上午 11:13
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    String str=request.getParameter("color");
    Cookie cookie=new Cookie("n",str);
    cookie.setMaxAge(600);//设置cookie的存活时间
    response.addCookie(cookie);//将Cookie保存于客服端
    Cookie[] cookies=request.getCookies();
    for(int i=0;i<cookies.length;i++)
    {
        if(cookies[i].getName().equals("n")){
        str=cookies[i].getValue();
        }
        break;
    }
    %>
    <p>欢迎你的登录</p>
    <div style="background-color:<%= str %>;width: 96px;height: 96px"> </div>
</body>
</html>
